/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package db;

import util.DBUtil;
import java.sql.Connection;
import java.sql.DriverManager;

/**
 *
 * @author hoang.nm
 */
public class ConnectionFactory {
    
    //username
    //password
    //server
    //port
    public static Connection createConnection() throws Exception {
        Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
        StringBuilder builder = new StringBuilder();
        builder.append("jdbc:sqlserver://").append(DBUtil.SERVER)
                .append(":").append(DBUtil.PORT)
                .append(";databaseName=").append(DBUtil.DB);
        Connection con = DriverManager.getConnection(builder.toString(), DBUtil.USER, DBUtil.PASS);
        return con;
    }
    
}
